namespace TomatoBreak.DataAccess.Mapping
{
    using DomainObjects;

    using NHibernate.Mapping.ByCode;

    public class UserMap : IClassMap
    {
        public void Map(ModelMapper mapper)
        {
            mapper.Class<User>(m =>
            {
                m.Id(u => u.Id);

                m.Property(
                    u => u.UserName, c =>
                {
                    c.NotNullable(true);
                    c.Length(32);
                    c.UniqueKey("UQ_User_UserName");
                });

                m.Property(u => u.Password, c =>
                {
                    c.NotNullable(true);
                    c.Length(64);
                });

                m.Property(u => u.Salt, c =>
                {
                    c.NotNullable(true);
                    c.Length(64);
                });

                m.Property(u => u.Email, c =>
                {
                    c.NotNullable(true);
                    c.Length(256);
                    c.UniqueKey("UQ_User_Email");
                });

                m.Property(u => u.Locked);
                m.Property(u => u.CreatedAt);
            });
        }
    }
}